package com.swjd.controller;

import com.swjd.pojo.Orders;
import com.swjd.service.impl.OrdersServiceImpl;
import com.swjd.util.BecomeJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by hxl on 2019/5/31  9:11
 */
@Controller
@RequestMapping(value = "action/", method = RequestMethod.POST)
public class OrdersController {
    @Autowired
    private OrdersServiceImpl ordersService;

    @ResponseBody
    @RequestMapping("insertByOrders")
    public String insertByOrders(@RequestBody Orders orders) {//添加订单信息
        return BecomeJson.isOk(ordersService.insertByOrders(orders));
    }

    @ResponseBody
    @RequestMapping("updateByOrders")
    public String updateByOrders(@RequestBody Orders orders) {//修改订单信息
        return BecomeJson.isOk(ordersService.updateByOrders(orders));
    }

    @ResponseBody
    @RequestMapping("selectUserByOrders")//用户查询订单信息
    public List<Orders> selectUserByOrders(@RequestParam("username") String username) {
        return ordersService.selectUserByOrders(username);
    }
}
